﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace memcached.Tx
{
    internal abstract class BaseOp : ITxCacheOperation
    {
        [System.Diagnostics.DebuggerHidden]
        protected BaseOp(ICache real, ICache temp)
        {
            Store = real;
            Temp = temp;
        }

        protected readonly ICache Store;

        protected readonly ICache Temp;

        public abstract string Name { get; }

        public abstract object Execute();

        public abstract bool Persist();

        public abstract bool Rollback();
    }

    internal abstract class KeyedOp : BaseOp
    {
        [System.Diagnostics.DebuggerHidden]
        protected KeyedOp(ICache real, ICache temp, string key)
            : base(real, temp)
        {
            Key = key;
        }

        protected readonly string Key;
    }

    internal abstract class ReadOnlyOp : KeyedOp
    {
        [System.Diagnostics.DebuggerHidden]
        public ReadOnlyOp(ICache real, ICache temp, string key)
            : base(real, temp, key)
        {
        }

        public override bool Persist()
        {
            return true;
        }

        public override bool Rollback()
        {
            return true;
        }
    }
}